﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace SQLTouch.Service.DataContracts
{
    [DataContract]
    public class SchemaData
    {
        [DataMember]
        private readonly List<TableData> tables;
        private IReadOnlyCollection<TableData> tablesReadOnly;

        private SchemaData()
        {

        }

        public SchemaData(IEnumerable<TableData> tables)
        {
            this.tables = tables.ToList();
        }

        public IReadOnlyCollection<TableData> Tables
        {
            get
            {
                if (tablesReadOnly == null)
                {
                    tablesReadOnly = new ReadOnlyCollection<TableData>(tables);
                }
                return tablesReadOnly;
            }
        }
    }
}
